import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gczn_hd/app/core/base/base_view.dart';
import 'package:gczn_hd/app/core/values/app_colors.dart';
import 'package:gczn_hd/app/core/values/text_styles.dart';
import 'package:gczn_hd/app/core/widget/custom_app_bar.dart';
import 'package:gczn_hd/app/modules/eam/spotcheck/widget/spot_log.dart';
import 'package:gczn_hd/app/modules/eam/spotcheck/widget/spot_plan.dart';

import 'package:get/get.dart';

import '../controllers/spotcheck_controller.dart';

class SpotcheckView extends BaseView<SpotcheckController> {

  SpotcheckView(){
    controller.onViewInit();
  }

  final double tableSize = 580.w;

  @override
  PreferredSizeWidget? appBar(BuildContext context) => AppBar(
    title: SizedBox(
      width: tableSize,
      child: TabBar(
          controller: controller.tabController,
          dividerHeight: 0.0,
          indicatorColor: AppColors.gcznPrimaryBlueColor, // 设置指示器颜色
          labelColor: AppColors.gcznPrimaryBlueColor, // 设置选中标签颜色
          unselectedLabelColor: AppColors.colorWhite, // 设置未选中标签颜色
          overlayColor: WidgetStateProperty.resolveWith<Color?>(
                (Set<WidgetState> states) {
              return Colors.transparent; // 去掉点击时的背景效果
            },
          ),
          tabs: controller.tabListString.map((item) => Tab(text: item, )).toList()
      ),
    ),
    backgroundColor: Colors.transparent,
    centerTitle: true,
    iconTheme: const IconThemeData(color: AppColors.appBarIconColor),
    flexibleSpace: FlexibleSpaceBar(
      background: Container(
        decoration: const BoxDecoration(
          gradient: LinearGradient(
            begin: Alignment.bottomCenter,
            end: Alignment.topCenter,
            colors: [
              Color.fromRGBO(18, 33, 47, 1),
              Color.fromRGBO(11, 23, 33, 1),
            ],
          ),
        ),
      ),
    ),
  );

  @override
  Widget body(BuildContext context) {
    return TabBarView(
      controller: controller.tabController,
      children: [
        SpotPlan(),
        SpotLog(),
      ],
    );
  }

}
